function loadImages(urls: Array<string>) {
  const promises: Array<Promise<HTMLImageElement>> = [];
  urls.forEach((url) =>
    promises.push(
      new Promise((resolve, reject) => {
        const img = new Image();
        img.onload = () => resolve(img);
        img.onerror = (err) => reject(err);
        img.src = url;
      })
    )
  );
  return Promise.all(promises);
}

function loadBackgroundResources() {
  return loadImages(["img/scene/scene.jpg"]);
}

export let backgroundResources: HTMLImageElement[];

export async function loadAllResources() {
  [backgroundResources] = await Promise.all([loadBackgroundResources()]);
}
